//40.组合总和II https://leetcode-cn.com/problems/combination-sum-ii/
class Solution {
public:
    void backtracking(vector<int>& candidates, int target,int count,int indexstart,vector<bool>&dure)
    {
        if(count == target)
        {
            result.push_back(temp);
            return;
        }
        if(count > target)
            return;
        for(int i = indexstart;i < candidates.size();i++)
        {
          
            if(i > 0 && candidates[i] == candidates[i-1] && !dure[i-1])
                continue;
            dure[i] = true;
            temp.push_back(candidates[i]);
            count += candidates[i];
            backtracking(candidates,target,count,i+1,dure);
            dure[i] = false;
            count -= candidates[i];
            temp.pop_back();
        }
    }
    vector<int> temp;
    vector<vector<int>> result;
    vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {
        vector<bool> dure(candidates.size(),false);
        sort(candidates.begin(),candidates.end());
        backtracking(candidates,target,0,0,dure);
        return result;
    }
};